package com.webserver.http;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class HttpContext {
    public static final char CR=13;//回车符
    public static final char LF=10;//换行符
    private static Map<String,String> mimeMapping=new HashMap<>();
    static {
        //初始化所有静态属性:静态块
        initMimeMapping();
    }
    private static void initMimeMapping(){
        try {
            Properties properties=new Properties();
            properties.load(
                    HttpContext.class.getResourceAsStream("web.properties")
            );
            properties.forEach((k,v)->mimeMapping.put(k.toString(),v.toString()));
            System.out.println(properties.size());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        System.out.println(getMimeType("mp3"));

    }
    public static String getMimeType(String ext){
        return mimeMapping.get(ext);
    }
}
